package com.bjgov.scoresys.service;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.ObjectNotFoundException;

import com.bjgov.scoresys.dao.ScoreHistoryDAO;
import com.bjgov.scoresys.entity.ScoreHistory;
import com.bjgov.scoresys.entity.User;
import com.bjgov.scoresys.util.Page;
import com.bjgov.scoresys.util.PageUtil;
import com.bjgov.scoresys.util.Result;

public class ScoreHistoryHandler {
	
	private static ScoreHistoryDAO dao = new ScoreHistoryDAO();
	
	public static int save(ScoreHistory entity) {
		return dao.save(entity);
	}
	
	public static List<ScoreHistory> getByUserIdProjectId(int userId, int projectId) {
		List<ScoreHistory> list = dao.findByUserIdProjectId(userId, projectId); 
		return list;
	}
	
	public static List<ScoreHistory> getByUserIdProjectIdItemIds(int userId, int projectId, String projectItemIds) {
		List<ScoreHistory> list = dao.findByUserIdProjectIdItemId(userId, projectId, projectItemIds); 
		return list;
	}
	
	public static List<ScoreHistory> getByUserIdProjectIdTopCateId(int userId, int projectId, int topCateId) {
		List<ScoreHistory> list = dao.findByUserIdProjectIdTopCateId(userId, projectId, topCateId); 
		return list;
	}
	
	public static ScoreHistory getByUidPidPitemId(int userId, int projectId, int projectItemId) {
		return dao.findByUidPidPitemId(userId, projectId, projectItemId);
	}
	
	public static String getDecScoreDate()
	{
		return dao.getDecScoreDate();
	}
	
	public static Result list(Page page) throws HibernateException,
			ObjectNotFoundException {
		int totalRecords = dao.count();
		page = PageUtil.createPage(page, totalRecords);
		List list = dao.getByPage(page);
		return new Result(list, page);
	}		
	                                                               
}
